/*
 * Copyright (c) 2017, Li Bo/Alex All rights reserved.
 * 
 * http://blog.sina.com.cn/alex4java
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
package com.hyts.jlogger.factory;

import java.util.logging.Logger;

import com.hyts.jlogger.util.StringUtils;


/**
 * @ClassName: LoggerFactory
 * @Description: build the prototype java.util.logging. <br>
 * 				 package operations<br>
 * @author: 李博/Alex
 * @date: 2017-3-2 下午3:20:29
 * @email:  alexlibochn@china-pui.com.cn
 */
public class LoggerFactory {
	
	/**
	 * @fieldName: LOGGER_GLOBAL_NAME
	 * @fieldType: String
	 * @Description: enclosable the Logger.GLOBAL_LOGGER_NAME 
	 */
	private static final String LOGGER_GLOBAL_NAME = Logger.GLOBAL_LOGGER_NAME;
	
	/**
	 * @Title: getLogger
	 * @Description: get System jdk java.util.logging logger 
	 * @param clazzName
	 * @return
	 * @return: Logger
	 */
	public static Logger getLogger(String clazzName){
		if(StringUtils.isNull(clazzName))
			return getLogger();
		return Logger.getLogger(clazzName);
	}
	
	/**
	 * @Title: getLogger
	 * @Description: get System jdk java.util.logging logger 
	 * @param clazzName
	 * @param resourceBundleName 
	 * @return
	 * @return: Logger
	 */
	public static Logger getLogger(String clazzName,String resourceBundleName){
		if(StringUtils.isNull(clazzName))
			return getLogger();
		return Logger.getLogger(clazzName);
	}
	
	/**
	 * @Title: getLogger
	 * @Description: get System jdk java.util.logging logger 
	 * @param clazz
	 * @return
	 * @return: Logger
	 */
	public static Logger getLogger(Class<?> clazz){
		if(null == clazz)
			return getLogger();
		return Logger.getLogger(clazz.getName());
	}
	
	/**
	 * @Title: getLogger
	 * @Description: get System jdk java.util.logging logger
	 * @param clazz
	 * @param resourceBundleName
	 * @return
	 * @return: Logger
	 */
	public static Logger getLogger(Class<?> clazz,String resourceBundleName){
		if(null == clazz)
			return getLogger();
		return Logger.getLogger(clazz.getName(),resourceBundleName);
	}
	
	/**
	 * @Title: getLogger
	 * @Description: default get Logger method<br>
	 * 				 invoke getAnonymousLogger()方法<br>	
	 * @return		 
	 * @return: Logger
	 */
	private static Logger getLogger(){
		return Logger.getAnonymousLogger();
	}
}
